package com.vip.jwt.common.utils.aliyun;

import cn.hutool.http.HttpRequest;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;

import java.util.HashMap;
import java.util.Map;

/**
 * 阿里云关于身份证工具类
 */
public class AliyunIDUtil {

    @Getter
    private static String APP_CODE;

    @Value("${aliyun-id-appcode}")
    public void setAppCode(String appCode) {
        APP_CODE = appCode;
    }

    /**
     * 判断身份证和姓名是否是一致
     * @return
     */
    public static String isIdentical(String idCard,String name){
        String url = "https://eid.shumaidata.com/eid/check";
        Map<String,Object> params = new HashMap<>(16);
        params.put("idcard", idCard);
        params.put("name", name);
        return HttpRequest.post(url).header("Authorization","APPCODE " + APP_CODE).form(params).execute().body();
    }

}
